﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace Projektet.View
{
    class MenuView
    {

        Texture2D _menuBackground;
        SpriteFont _spriteFont;
        //string _menuText = "test";
        private int _levelCount;
        private Rectangle _menuRectangle;

        public MenuView(int levelCount)
        {
            _levelCount = levelCount;
            int width = 30;
            int height = 50;
            _menuRectangle = new Rectangle(55 - (width / 2), 50 - (height / 2), width, height);
        }

        public void LoadContent(ContentManager contManager)
        {
            _menuBackground = contManager.Load<Texture2D>("menuBackground");
            _spriteFont = contManager.Load<SpriteFont>("SpriteFont1");
        }

        public void Draw(SpriteBatch spriteBatch, Controller.GameState gameState)
        {
            Rectangle visualRect = Camera.GetVisualRectangleNoOffset(_menuRectangle);
            Vector2 textPos = new Vector2(visualRect.X + 5, visualRect.Y);
            string text = "";
            switch(gameState)
            {
                case Controller.GameState.InMenu:
                    text = TextFactory.GetMenuText(_levelCount);
                    break;
                case Controller.GameState.InUpgradeMenu:
                    text = TextFactory.GetUpgradeText();
                    break;
                case Controller.GameState.Gameover:
                    text = TextFactory.GetGameoverScreenText();
                    break;
                case Controller.GameState.VictoryScreen:
                    text = TextFactory.GetVictoryScreenText();
                    break;
                case Controller.GameState.InInfo:
                    text = TextFactory.GetInfoText();
                    break;
            }

            spriteBatch.Draw(_menuBackground, visualRect, Color.White);
            spriteBatch.DrawString(_spriteFont, text, textPos, Color.White);
        }
    }
}
